﻿using System;
using fastCSharp;

namespace diantou.web.contest
{
    /// <summary>
    /// 问题
    /// </summary>
    [fastCSharp.code.cSharp.webView(IsPool = true, IsReferer = false)]
    partial class problem : problemView<problem>
    {
        /// <summary>
        /// OJ问题测试数据客户端缓存
        /// </summary>
        private static readonly fastCSharp.sql.logCache<int, diantou.dataAccess.problemTestData>.array testDataCache = new fastCSharp.sql.logCache<int, diantou.dataAccess.problemTestData>.array(diantou.dataAccess.tcpCall.problemTestData.onContestTestLog, 8);
        /// <summary>
        /// OJ问题测试数据
        /// </summary>
        [fastCSharp.emit.webView.clearMember]
        private diantou.dataAccess.problemTestData testData1;
        /// <summary>
        /// OJ问题测试数据
        /// </summary>
        private diantou.dataAccess.problemTestData TestData1
        {
            get
            {
                if (testData1 == null)
                {
                    fastCSharp.sql.logCache<int, diantou.dataAccess.problemTestData>.array.value value = testDataCache.Get(problem.Id);
                    if (value.Value == null)
                    {
                        value.Value = diantou.dataAccess.tcpCall.problemTestData.getTest1(problem.Id, 1 << 10);
                        testDataCache.Set(ref value);
                    }
                    if ((testData1 = value.Value) == null) testData1 = diantou.dataAccess.problemTestData.NullData;
                }
                return testData1;
            }
        }
        /// <summary>
        /// 测试输入数据
        /// </summary>
        [fastCSharp.code.cSharp.webView.outputAjax]
        private string TestDataInput
        {
            get { return TestData1.Input; }
        }
        /// <summary>
        /// 测试输出数据
        /// </summary>
        [fastCSharp.code.cSharp.webView.outputAjax]
        private string TestDataOutput
        {
            get { return TestData1.Output; }
        }
        /// <summary>
        /// 是否正在提交代码
        /// </summary>
        [fastCSharp.code.cSharp.webView.outputAjax]
        private bool isSubmit;
        /// <summary>
        /// 是否可以提交代码
        /// </summary>
        private bool canSubmit
        {
            get
            {
                if (currentUser != null)//date.NowSecond < contest.EndTime && 
                {
                    //if (currentUser.Permission == dataModel.user.permission.Admin || problem.UserId == currentUser.Id || problem.TestUserId == currentUser.Id) return true;
                    return date.Now >= contest.StartTime && userContest.IsRegister;
                }
                return false;
            }
        }
        /// <summary>
        /// 是否可以提交竞赛代码
        /// </summary>
        private bool canContest
        {
            get
            {
                return date.NowSecond < contest.EndTime;
            }
        }
    }
}
